home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / os2 / adaptor.zip / ADAPT.ZIP / adaptor / examples / simple / pi.f < prev    next >
Text File  |  1993-11-30  |  513b  |  21 lines

  1. c     numerical integration to calculate pi
  2.  
  3.       program pi
  4.       integer i, n
  5.       real*8 w, v(:), gsum, pi
  6.  
  7.       print *, 'Input number of points : '
  8.       read *, n
  9.       call cm_timer_clear (0)
  10.       call cm_timer_start (0)
  11.       w = 1.0 / n
  12.       allocate (v(n))
  13.       v = ([1:n] -0.5 )* w
  14.       v = 4.0 / (1.0 + v * v)
  15.       gsum = sum (v)
  16.       call cm_timer_stop (0)
  17.       print *, 'pi ist approximated with ', gsum *w
  18.       call cm_timer_print (0)
  19.       deallocate (v)
  20.       end
  21.